package com.cesce.batch.cobros.validation;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springmodules.validation.valang.ValangException;
import org.springmodules.validation.valang.functions.AbstractFunction;
import org.springmodules.validation.valang.functions.Function;


public class ValidateExistenciaCampos extends AbstractFunction {
	
		protected final Log logger = LogFactory.getLog(getClass());
		

		Boolean validacion= Boolean.FALSE;

	    public ValidateExistenciaCampos(Function[] arguments, int line, int column) {
	        super(arguments, line, column);
	        definedExactNumberOfArguments(3);
	    }
	
	    
		@SuppressWarnings("unchecked")
		protected Object doGetResult(Object target) throws Exception {
			String spto= (String) getArguments()[0].getResult(target);
			String codigocesce = (String) getArguments()[1].getResult(target);
			String nif = (String) getArguments()[2].getResult(target);
			validacion= Boolean.FALSE;
		
			
		if ((spto != null && !spto.isEmpty()) || (codigocesce != null && !codigocesce.isEmpty()) || (nif != null && !nif.isEmpty())) {
			validacion= Boolean.TRUE;
		}
			
	
//		if(validacion==Boolean.FALSE) {
//			throw new ValangException("Falta campo obligatorio: nif | codigocesce | spto", 1,1);
//		}
		
		return validacion;
	}

}

